package types

// NetData 网络统计数据结构
type NetData struct {
	Received      uint64 // 接收的字节数
	Sent          uint64 // 发送的字节数
	TotalUpload   uint64 // 总上传流量
	TotalDownload uint64 // 总下载流量
	TotalDropped  uint64 // 总丢包数据
	Packets       uint64 // 总包数
	IsVirtual     bool   // 是否为虚拟网卡
}

// InterfaceInfo 网卡基本信息结构
type InterfaceInfo struct {
	ID        string `json:"id"`        // 网卡唯一ID
	Name      string `json:"name"`      // 网卡名称
	Type      string `json:"type"`      // 网卡类型: physical/virtual
	IsVirtual bool   `json:"isVirtual"` // 是否为虚拟网卡
	Status    string `json:"status"`    // 状态: active/inactive
}

// SpeedData 网络速度数据结构
type SpeedData struct {
	DownloadSpeed float64 // 接收速率 (字节/秒)
	UploadSpeed   float64 // 发送速率 (字节/秒)
}

// NetworkSummary 网络汇总统计
type NetworkSummary struct {
	TotalInterfaces    int     `json:"total_interfaces"`
	ActiveInterfaces   int     `json:"active_interfaces"`
	VirtualInterfaces  int     `json:"virtual_interfaces"`
	PhysicalInterfaces int     `json:"physical_interfaces"`
	TotalDownloadSpeed float64 `json:"total_download_speed"` // Mbps
	TotalUploadSpeed   float64 `json:"total_upload_speed"`   // Mbps
	TotalDownloadGB    float64 `json:"total_download_gb"`
	TotalUploadGB      float64 `json:"total_upload_gb"`
	UpdateTime         string  `json:"update_time"`
}

// NetworkAPIResponse 网络监控API标准响应
type NetworkAPIResponse struct {
	Interfaces map[string]interface{} `json:"interfaces"`
	Summary    NetworkSummary         `json:"summary"`
}

// SpeedAPIResponse 网速API响应
type SpeedAPIResponse map[string]SpeedInfo

// SpeedInfo 单个网卡速度信息
type SpeedInfo struct {
	ReceivedMbps    float64 `json:"received_mbps"`
	SentMbps        float64 `json:"sent_mbps"`
	TotalReceivedGB float64 `json:"total_received_gb"`
	TotalSentGB     float64 `json:"total_sent_gb"`
	PacketLoss      float64 `json:"packet_loss"`
	IsVirtual       bool    `json:"isVirtual"`
	// 新增格式化字符串字段
	ReceivedMbpsText  string `json:"received_mbps_text"`  // 如: "12.5 Mbps"
	SentMbpsText      string `json:"sent_mbps_text"`      // 如: "8.3 Mbps"
	TotalReceivedText string `json:"total_received_text"` // 如: "1.2 GB"
	TotalSentText     string `json:"total_sent_text"`     // 如: "856.7 MB"
	PacketLossText    string `json:"packet_loss_text"`    // 如: "0.1%"
}

// InterfaceListResponse 网卡列表API响应
type InterfaceListResponse struct {
	Interfaces []InterfaceInfo      `json:"interfaces"`
	Count      int                  `json:"count"`
	Summary    InterfaceListSummary `json:"summary"`
}

// InterfaceListSummary 网卡列表汇总
type InterfaceListSummary struct {
	TotalInterfaces    int    `json:"total_interfaces"`
	PhysicalInterfaces int    `json:"physical_interfaces"`
	VirtualInterfaces  int    `json:"virtual_interfaces"`
	ActiveInterfaces   int    `json:"active_interfaces"`
	UpdateTime         string `json:"update_time"`
}

// SSENetworkData SSE推送的网络数据
type SSENetworkData struct {
	Interfaces map[string]interface{} `json:"interfaces"`
	Summary    SSESummary             `json:"summary"`
	System     map[string]interface{} `json:"system"`
}

// SSESummary SSE推送的汇总数据
type SSESummary struct {
	TotalInterfaces int     `json:"total_interfaces"`
	TotalDownload   float64 `json:"total_download"`
	TotalUpload     float64 `json:"total_upload"`
	TotalLoss       float64 `json:"total_loss"`
}

// InterfaceData SSE推送的单个网卡数据
type InterfaceData struct {
	ID              string  `json:"id"`
	Name            string  `json:"name"`
	ReceivedMbps    float64 `json:"received_mbps"`
	SentMbps        float64 `json:"sent_mbps"`
	TotalReceivedGB float64 `json:"total_received_gb"`
	TotalSentGB     float64 `json:"total_sent_gb"`
	Dropped         uint64  `json:"dropped"`
	Status          string  `json:"status"`
	IsVirtual       bool    `json:"isVirtual"`
	// 新增格式化字符串字段
	ReceivedMbpsText  string `json:"received_mbps_text"`  // 如: "12.5 Mbps"
	SentMbpsText      string `json:"sent_mbps_text"`      // 如: "8.3 Mbps"
	TotalReceivedText string `json:"total_received_text"` // 如: "1.2 GB"
	TotalSentText     string `json:"total_sent_text"`     // 如: "856.7 MB"
	DroppedText       string `json:"dropped_text"`        // 如: "1.2K packets"
	UpdateTime        string `json:"update_time"`         // 如: "2024-01-01 12:00:01"
}
